<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<!-- v-on 指令，增加点击事件 -->
<body>
    <div id="app">
        <div>
           <h1>{{count}}</h1>

           <div>基础使用方式  v-on:click </div>
           <!-- 基础使用方式 -->
           <button v-on:click="sub">-</button>
           <button v-on:click="add">+</button>

           <br>

           <div>简写使用方式  @click </div>
           <button @click="sub">-</button>
           <button @click="add">+</button>

        </div>
    </div>
    <script src="js/vue.js"></script>

    <script>
        const HelloVue = {
            data(){
                return {
                   count : 0,
                }
            },
            methods: {
                sub(){
                    this.count--;
                },
                add(){
                    this.count++;
                }
            }
        };

        const app = Vue.createApp(HelloVue).mount("#app");
       
    </script>
</body>
</html>